package com.meixiang.activity.homes.staging;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.meixiang.R;
import com.meixiang.adapter.home.RepaymentDetailAdapter;
import com.meixiang.main.BaseActivity;
import com.meixiang.recyclerview.RecyclerOnItemClickListener;
import com.meixiang.tool.Tool;
import com.meixiang.view.DividerItemDecoration;
import com.meixiang.view.TitleView;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author yinsujun  Created at 2016/5/5 15:55
 *         账单详情
 */
public class CheckDetailsActivity extends BaseActivity{
    @Bind(R.id.title)
    TitleView title;
    @Bind(R.id.check_detail_tv_title)
    TextView tvTitle;
    @Bind(R.id.check_detail_tv_repayment_time)
    TextView tvRepaymentTime;
    @Bind(R.id.check_detail_tv_total_money1)
    TextView tvTotalMoney1;
    @Bind(R.id.check_detail_tv_total_money)
    TextView tvTotalMoney;
    @Bind(R.id.check_detail_view_total_money)
    View checkDetailViewTotalMoney;
    @Bind(R.id.check_detail_tv_repay_money1)
    TextView tvRepayMoney1;
    @Bind(R.id.check_detail_tv_repay_money)
    TextView tvRepayMoney;
    @Bind(R.id.check_detail_relative_total_money)
    RelativeLayout relativeTotalMoney;
    @Bind(R.id.check_detail_recycler)
    RecyclerView recycler;
    @Bind(R.id.check_detail_bt_repayment)
    Button btRepayment;
    private RepaymentDetailAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_check_detail);
        ButterKnife.bind(this);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initTitle() {
        setTitle("账单详情");

    }

    @Override
    protected void initView() {
        mAdapter=new RepaymentDetailAdapter(context,1);
        LinearLayoutManager layoutManager=new LinearLayoutManager(context);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recycler.setLayoutManager(layoutManager);
        recycler.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
        recycler.setAdapter(mAdapter);
        mAdapter.setOnItemClickListener(new RepaymentDetailAdapter.OnItemClickListener(){
            @Override
            public void onItemClick(View view, int position) {
                Intent intent=new Intent(context,StagingDetailActivity.class);
                startActivity(intent);
            }
        });
//        recycler.addOnItemTouchListener(new RecyclerOnItemClickListener(recycler){
//
//            @Override
//            public void OnItemClickListener(RecyclerView.ViewHolder viewHolder) {
//                Tool.showTextToast(context,"点击"+viewHolder.getLayoutPosition());
//
//            }
//
//            @Override
//            public void OnLongClickListener(RecyclerView.ViewHolder viewHolder) {
//                Tool.showTextToast(context,"长按"+viewHolder.getLayoutPosition());
//
//            }
//        });
    }

    @Override
    protected void setData() {

    }

    @OnClick({R.id.check_detail_relative_total_money, R.id.check_detail_bt_repayment})
    void click(View view) {
        Intent intent = new Intent();
        if (view.equals(relativeTotalMoney)) {
            intent.setClass(context, RepaymentDetailActivity.class);
        }else if(view.equals(btRepayment)){
            intent.setClass(context, RepaymentActivity.class);
        }
        startActivity(intent);
    }

    @Override
    public void onClick(View v) {

    }

}
